#include "States.h"

States::States() {
	this->initStates();
}

void States::initStates() {
	states = new std::map<byte, bool>();
}

void States::addState(byte state, bool value) {
	//check null
	if (states == NULL) return;
	states->insert(std::make_pair(state, value));
}

bool States::checkState(byte state) {
	//check null
	if (states == NULL) return false;
	//search state
	it = states->find(state);
	//check it
	if (it == states->end()) return false;
	//return value
	return it->second;
}

void States::setState(byte state, bool value) {
	//check states null
	if (states == NULL) return;
	//search state
	it = states->find(state);
	//if exist set state to value
	if (it == states->end()) return;
	it->second = value;
	if (value) {
		currentState = state;
	}
}